﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SimpleBlog.Mvc
{
    public class ErrorViewAttribute : AuthorizeAttribute
    {
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            //Only can exceute if 
            Exception exception = filterContext.RouteData.Values["exception"] as Exception;
            if (exception == null)
            {
                throw new HttpException(404, "Action not accesible.");
            }
        }
    }
}